package com.weishuang.gateway.utils;

import org.apache.commons.lang.StringUtils;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

public class ListUtil {

    public static String list2String(Collection<String> list) {
        if (CollectionUtils.isEmpty(list)) {
            return "";
        }
        return StringUtils.join(list, ',');
    }


    public static List<String> string2List(String str) {
        if (StringUtils.isEmpty(str)) {
            return new ArrayList<>();
        }
        String[] split = str.split(",");
        return Arrays.asList(split);
    }

}
